import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'

Vue.use(Vuex)

// 应用初始状态
const state = {
    count: 10,
    companyList: [],//公司列表
    token:'',
    messageNum:0,
}

// 定义所需的 mutations
const mutations = {
    setMessageNum(state,data){
        state.messageNum = data;
    },
    INCREMENT(state) {
        state.count++
    },
    DECREMENT(state) {
        state.count--
    },
    //设置公司列表
    setCompanyList(state,list){
        state.companyList = list;
    },
    //设置token
    setToken(state,token){
        state.token = token;
        sessionStorage.setItem('token',token);
    }

}

// 创建 store 实例
export default new Vuex.Store({
    actions,
    getters,
    state,
    mutations
})